import cssFunc from "css-color-function"

const formula: {
  [key: string]: string
} = {}
const colorNumber = 10

for (let i = 1; i < colorNumber; i++) {
  formula[`primary-light-${i}`] = `color(example tint(${i}0%))`
}

export const generateColors = (primary: string) => {
  const colors: Record<string, string> = {}
  Object.entries(formula).forEach(([key, value]) => {
    const color = value.replace("example", primary)
    colors[key] = cssFunc.convert(color)
  })

  return colors
}

export const setColors = (colors: Record<string, string>) => {
  Object.entries(colors).forEach(([key, value]) => {
    document.documentElement.style.setProperty(`--el-color-${key}`, value)
  })
}
